package com.learn.strategy.ext;

import com.learn.strategy.FormSubmitHandler;
import com.learn.strategy.dto.CommonPairResponse;
import com.learn.strategy.dto.FormSubmitRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * @author tuzhijin
 * @version Id: FormFaasSubmitHandler.java, v 0.1 2021/3/21 下午2:11 tuzhijin Exp $$
 */
@Component
@Slf4j
public class FormFaasSubmitHandler implements FormSubmitHandler {


    @Override
    public String getSubmitType() { return "faas"; }

    @Override
    public CommonPairResponse handleSubmit(FormSubmitRequest request) {
        log.info("FaaS 模式的提交：userId={}, formInput={}", request.getUserId(), request.getFormInput());

        // 进行 FaaS 函数调用，并获得业务方返回的提示信息和业务数据
        CommonPairResponse response = faasSubmitData(request);

        return response;
    }

    private CommonPairResponse faasSubmitData(FormSubmitRequest request) {
        return new CommonPairResponse();
    }

}

